home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
NJMOVE.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-01-16
|
46KB
|
2,047 lines
page 60,150
title NJMOVE - Nifty James' MOVE Utility
subttl (C) 1989 Blaszczak
;
; Nifty James' Famous Move Utility
; Version 1.00 of 16 January 1989
; (C) Copyright 1989 By Mike Blaszczak
;
;
; This file is written for the Microsoft Macro Assembler,
; Version 5.10 or higher. The program will not properly
; operate under any DOS version less than 2.00, but will
; work with any PC-DOS or MS-DOS Versions 2.00 and above.
; This is an .EXE file, and should not be run through
; EXE2BIN. The executable file should be packed, or the
; LINK option /EXEPACK should be used.
;
; ----------------------------------------------------------------------------
; ASCII Equates
eos equ 000h ; end-of-string character
bell equ 007h ; bell beeper
bs equ 008h ; back-space
tab equ 009h ; tab
lf equ 00Ah ; line-feed character
cr equ 00Dh ; carriage return
ctrlz equ 01Ah ; control zee (aka, EOF)
eof equ ctrlz
space equ 020h ; blank space
; ----------------------------------------------------------------------------
; DOS Function Calls and constants
INTDOS equ 021h
STDIN equ 0 ; standard output file handle
STDOUT equ 1 ; standard input file handle
NormalAttrib equ 000h ; normal attribute byte (nothing set)
SubDirAttrib equ 010h ; attribute for a directory
PutChar equ 002h ; put character to stdout
GetChar equ 007h ; get char from stdin, with no echo
GetDefDisk equ 019h ; get current default disk drive
SetDTA equ 01Ah ; set the DOS DTA address
FreeSpace equ 036h ; get disk free space
CreateHandle equ 03Ch ; create a file handle
OpenHandle equ 03Dh ; open a file handle
CloseHandle equ 03Eh ; close a file handle
ReadHandle equ 03Fh ; read from a file or device
WriteHandle equ 040h ; write to a file or device
DeleteFile equ 041h ; delete a file name
GetAttrib equ 04300h ; get file attributes
SetAttrib equ 04301h ; set file attributes
IOCTL equ 044h ; I/O control/status call
GetDefDir equ 047h ; get current default directory
Terminate equ 04Ch ; terminate this program
FindFirst equ 04Eh ; find first file matching wildcard
FindNext equ 04Fh ; find next file matching wildcard
RenameFile equ 056h ; rename a file
GetDateTime equ 05700h ; get date or time
SetDateTime equ 05701h ; set date or time
NormalizePath equ 060h ; normalize pathname
GetPSP equ 062h ; get the programs PSP
; note that NormalizePath is an undocumented call. DS:SI points to a
; path specification which may contain a drive specifier. ES:DI points
; to a buffer for the normalized pathname. The file simply fixes the
; "." and ".." references in the file, making the pathname as short as
; possible. This expansion is simply used so the user knows *exactly*
; where the file is coming from. Microsoft, in their infinite (heh)
; wisdom (hah) did not document this very useful function call.
; ----------------------------------------------------------------------------
; ERRORLEVEL values that we return
ERR_None equ 0 ; none!
ERR_Usage equ 1 ; problem on command line
ERR_NotFound equ 2 ; file not found
ERR_BadFile equ 3 ; given a device, or an unparsable
ERR_CopyProblem equ 4 ; problem while copying
ERR_Renaming equ 5 ; problem while renaming
; These are the data structures used in this program. The first is used
; internally to describe the way a file name is broken down into its
; components.
FileDriveLen equ 3
FilePathLen equ 65
FileNameLen equ 9
FileExtLen equ 5
FileNameS struc
drive db FileDriveLen dup(?) ; drive B:
path db FilePathLen dup(?) ; path \bin\booger
fname db FileNameLen dup(?) ; filename njmove
fext db FileExtLen dup(?) ; extension asm
FileNameS ends
; This data structure is the one that DOS uses to store the DTA. When
; we call FINDFIRST and FINDNEXT, this information will be set up to contain
; the rest of the file that we are moving.
DOSDTAS struc
_dta_reserved db 21 dup (?) ; reserved space
dta_attribute db ? ; attribute byte
dta_time dw ? ; file modification time
dta_date dw ? ; file modification date
dta_size dd ? ; file size (doubleword!)
dta_fname db 13 dup (?) ; file name (ASCIIZ)
DOSDTAS ends
; ============================================================================
.model small
.stack 0100h ; get a *real* stack
; ============================================================================
; Our data area follows. This data area contains both initialized and
; uninitialized data.
.data
Banner db "Nifty James' Famous Move Utility",cr,lf
db "Version 1.00 of 16 January 1989",cr,lf
db "(C)Copyright 1989 by Mike Blaszczak",cr,lf
db lf,eos
NoSpace db "NJMOVE: Destination device ran out of space"
CRLFSet db cr,lf,eos
NoSelf db "NJMOVE: A File can not be moved into itself"
db cr,lf,eos
CantWrite db "NJMOVE: Couldn't write to destination device"
db cr,lf,eos
CantRead db "NJMOVE: Couldn't read from source device"
db cr,lf,eos
CantSDevice db "NJMOVE: Can't move from a device"
db cr,lf,eos
CantDDevice db "NJMOVE: Can't move to a device"
db cr,lf,eos
BadSource db "NJMOVE: Bad Source File Specification"
db cr,lf,eos
BadDest db "NJMOVE: Bad Destination File Specification"
db cr,lf,eos
CouldntRename db "NJMOVE: Could not perform rename operation"
db cr,lf,eos
NameCollide db "NJMOVE: File naming collision; file already exists"
db cr,lf,eos
CouldntDIR db "NJMOVE: Couldn't get default directory of drive "
db eos
NoMatches db "NJMOVE: No files matched ",eos
UAborted db cr,lf,"NJMOVE: User Aborted",cr,lf,lf,eos
Usage db "Usage:",cr,lf
db tab,"NJMOVE <source> <dest> [/C]",cr,lf
db lf
db tab,"<source>",tab,"source file name",cr,lf
db tab,"<dest>",tab,tab,"destination file name",cr,lf
db tab,tab," both file names may "
db "contain wildcards",cr,lf
db tab,"[/C]",tab,"specifies optional confirmation"
db cr,lf,lf,eos
MovingMess db "Moving ",eos
MoveCMess db "Move ",eos
CopyingMess db "Copying ",eos
CopyCMess db "Copy ",eos
ToMess db " to ",eos
BackSlash db "\",eos
DotStar db "."
Star db "*",eos
ConfirmPrompt db "? [No] ",eos
confirmmode db 0 ; set if the /C was to be found
copymode db 0 ; set to one if we must copy
; from disk to disk instead of
; just renaming the files
even
sourcespec dw 0 ; source file specification
destspec dw 0 ; destination spec
sourcewildf db 0 ; set if sourcef has wildcard name
sourcewilde db 0 ; set if sourcef has wildcard ext
sourcehase db 0 ; set if sourcef has extension
sourcef FileNameS <> ; source description
sourcefile db 64 dup (0) ; total file name
destwildf db 0 ; set if destf has wildcard name
destwilde db 0 ; set if destf has wildcard ext
desthase db 0 ; set if destf has extension
destf FileNameS <> ; destination description
destfile db 64 dup (0) ; total file name
mydta DOSDTAS <> ; a place for DOS to store its stuff
; during FINDFIRST + FINDNEXT
; These variables are used by the copyfile procedure
sourceh dw ? ; handle for source file
desth dw ? ; destination file handle
; ----------------------------------------------------------------------------
; These areas are all data buffers that are not initialized, generally.
even
argvectors dw 64 dup (0) ; pointers to each argumnet
argcount dw 0 ; count of arguments
argbuff db 128 dup (0) ; buffer to hold args for DS access
CopyBufferLen equ 16384
copybuffer db CopyBufferLen dup (?)
; this buffer is used while copying
temppath db FilePathLen dup(?)
; area used by check4path and
; normalizepath
fixedpath db FilePathLen dup(?)
; area used by normalize path, too.
; This area is used by the confirm procedure
confirmreply db ?
; ============================================================================
; This is the program code. The execution of the program starts at the
; very first instruction here.
.code
; first, put the banner of our program on the screen
mov ax,@data
mov ds,ax
mov si,offset Banner
call putstr
; set the DTA to point to ou